<!DOCTYPE html>
<html ng-app="app">
<head>
    <meta charset="utf-8">
    <title>MVC Model:ng-controller</title>
    <script type="text/javascript" src="../angular.js"></script>
</head>
<body>
    <div>用户输入信息：</div>
    <div ng-controller="UserInfoController">
        <div>用户名：<input type="text" ng-model="name" placeholder="请输入用户名" /></div>
        <div>密码：<input type="password" ng-model="password" placeholder="请输入密码" /></div>
        <p>您输入的用户名：{{name}}</p>
        <p>您输入的密码：{{password}}</p>
    </div>
    <br/>
    <div>简单运算处理：</div>
    <div  ng-controller="CalcController as calc">
        <div>乘数：<input type="number" ng-model="mult" /></div>
    <div>被乘数：<input type="number" ng-model="multee" /></div>
    <div>运算结果：{{calc.totalPrice()}}</div>
    </div>
    <script type="text/javascript">
        function CalcControllerDemo($scope,$log){
            $scope.mult = 10;
            $scope.multee = 2;
            this.totalPrice = function(){
                $log.info("CalcController->name:"+$scope.name);
                $log.info("CalcController->password:"+$scope.password);
                return $scope.mult*$scope.multee;
            }
        }
        function UserInfoDemo($scope,$log){
            $scope.name = "admin";
            $scope.password = "111111";
            $log.info("UserInfoController->name:"+$scope.name);
            $log.info("UserInfoController->password:"+$scope.password);
        }
        var app = angular.module("app",[]);
        app.controller("CalcController",CalcControllerDemo);// 声明一个控制器
        app.controller("UserInfoController",UserInfoDemo);// 声明一个控制器
    </script>
</body>
</html>